<?php

class LinkController extends AppController
{
	protected $model;
	
	public function __construct()
	{
		$this->model = new LinkModel();
		parent::__construct();
	}
	
    public function index()
    {
    	o('这是导航站');
    }

    public function addCate()
    {
    	if(G('step')==2){
			if($this->model->addCate(array('name' => P('name')))){
				o('保存成功');
			}else{
				o('保存数据失败', ACTION_FALSE);
			}
    	}
    	$this->view->title = "添加分类";
    	$this->view->cateName = p('name');
    	$this->view->show();
    }
    
    public function addSubCate()
    {
    	if(G('step')==2){
    		if($this->model->addSubCate(array('name' => P('subName'), 'cate_id' => P('cateId')))){
    			$this->view->actionMsg = '保存成功';
    		}else{
    			$this->view->actionMsg = '保存数据失败' . $this->model->msg;
    		}
    	}
    	$this->view->subCateList = $this->model->getSubCateList(P('cateId'));
    	$this->view->cateList = $this->model->getCateList();
    	$this->view->title = "添加二级分类";
    	$this->view->subCateName = P('subName');
    	$this->view->selected = P('cateId');
    	
    	$this->view->addCss('tool');
    	
    	$this->view->show();
    }
}